package zhai.docking.alipay.domain.base.bizlog;

import lombok.Data;

import java.io.Serializable;

/**
 * @author Created by 翟凤玺
 * @package zhai.docking.alipay.domain.base.bizlog
 * @project-name zhai-docking-alipay
 * @description 业务日志持久化 结果
 * @create-datetime 2020-1-19 11:52
 */
@Data
public class BizLogResult<T> implements Serializable {

    /**
     * 返回编码
     */
    private String returnCode;

    /**
     * 返回数据
     */
    private T data;

    /**
     * 成功
     */
    public static final String RETURN_CODE_SUCCESS = "SUCCESS";
    /**
     * 失败
     */
    public static final String RETURN_CODE_FAILTURE = "FAILURE";

    /**
     * 成功
     */
    public static BizLogResult success() {
        BizLogResult result = new BizLogResult();
        result.setReturnCode(BizLogResult.RETURN_CODE_SUCCESS);
        return result;
    }

    public static <T> BizLogResult<T> success(T data) {
        BizLogResult result = new BizLogResult();
        result.setData(data);
        result.setReturnCode(BizLogResult.RETURN_CODE_SUCCESS);
        return result;
    }

    /**
     * 失败
     */
    public static BizLogResult failture() {
        BizLogResult result = new BizLogResult();
        result.setReturnCode(BizLogResult.RETURN_CODE_FAILTURE);
        return result;
    }

    public static <T> BizLogResult<T> failture(T data) {
        BizLogResult result = new BizLogResult();
        result.setData(data);
        result.setReturnCode(BizLogResult.RETURN_CODE_FAILTURE);
        return result;
    }

}